{template 'public/header'}
{template 'public/comhead'}

<ul class="nav nav-tabs">
    <li {if $operation == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('shouqianbacode', array('op' => 'display'))}">管理激活码</a></li>
    <li {if $operation == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('shouqianbacode', array('op' => 'post'))}">添加激活码</a></li>
</ul>
{if $operation == 'post'}
<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <div class="panel panel-default">
            <div class="panel-heading">
                激活码编辑
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">激活码</label>
                    <div class="col-sm-9">
                        <input type="text" name="code" class="form-control" value="{$school['code']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">设备ID</label>
                    <div class="col-sm-9">
                        <input type="text" name="device_id" class="form-control" value="{$school['device_id']}" />
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group col-sm-12">
            <input type="submit" name="submit" value="保存设置" class="btn btn-primary col-lg-3" />
            <input type="hidden" name="token" value="{$_W['token']}" />
        </div>
    </form>
</div>
{elseif $operation == 'display'}
<div class="main">
    <div class="panel panel-default">
        <form action="" method="post" class="form-horizontal form" >
            <input type="hidden" name="storeid" value="{$storeid}" />
            <div class="table-responsive panel-body">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width:100px;">编号</th>
                        <th>激活码</th>
                        <th>设备ID</th>
                        <th>终端号</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="level-list">
                    {loop $list $row}
                    <tr>
                        <td>{$row['id']}</td>
                        <td><span class="label label-success">{$row['code']}</span>
                        </td>
                        <td>
                            <span class="label label-success">{$row['device_id']}</span>
                        </td>
                        <td>
                            <span class="label label-success">{$row['terminal_sn']}</span>
                        </td>
                        <td>
                            {if $row['result_code'] == ''}
                            <span class="label label-danger">未激活</span>
                            {elseif $row['result_code'] == '200'}
                            <span class="label label-success">已激活</span>
                            {else}
                            <span class="label label-danger">激活失败{$row['result_code']}</span>
                            {/if}
                        </td>
                        <td>
                            {if $row['result_code'] != '200'}
                            <a class="btn btn-success btn-sm" href="{php echo $this->createWebUrl('shouqianbacode', array('id' => $row['id'], 'op' => 'setstatus'))}" title="激活" onclick="return confirm('确认激活吗？');return false;"> 激活</a>{/if}

                            <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('shouqianbacode', array('op' => 'post', 'id' => $row['id']))}" title="编辑">改</a>&nbsp;&nbsp;<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('shouqianbacode', array('op' => 'delete', 'id' => $row['id']))}" onclick="return confirm('确认删除吗？');return false;" title="删除">删</a>


                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </form>
    </div>
    {$pager}
</div>
{/if}
{if $_W['isfounder']}
{template 'common/footer'}
{else}
{template 'public/footer'}
{/if}